﻿using System;
using Gp.Scripts.Data;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace Gp.Scripts.GUI {
    public class UnitInfoBuffItem : MonoBehaviour {
        public Image icon;
        public TMP_Text text;

        public TMP_Text level;


        public void RenderBuff(BaseBuff buff) {
            if (buff == null) {
                gameObject.SetActive(false);
                return;
            }

            var info = buff.OnIconRender();


            icon.sprite = info.Icon;
            text.text = info.BuffName;
            var txt = info.Duration == 0 ? "" : info.Duration.ToString();
            level.text = txt;
        }
    }
}